package com.example.jvm.lesson11;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Date 2024-01-22
 * @Author Jonathan
 */
public class FutureTest3 {
    public static void main(String[] args) throws Exception {
        ExecutorService executor = Executors.newCachedThreadPool();
        CompletableFuture<Void> runFuture = CompletableFuture.runAsync(() -> {
            System.out.println("run------,关注公众号:捡田螺的小男孩");
        }, executor);

        CompletableFuture<String> async = CompletableFuture.supplyAsync(() -> {

            System.out.println("run,关注公众号:捡田螺的小男孩");
            return "hello world";
        }, executor);

        System.out.println(async.join());
        ///System.out.println(async.get());
        Thread.currentThread().join();
    }
}
